package com.yswy.common.exception;


import com.yswy.common.enums.MsgEnum;

/**
 * 业务异常
 * @author yanwei
 */
public class BusinessException extends RuntimeException implements ICommonMessage {

    private static final long serialVersionUID = 1L;

    /**
     * code
     */
    private final int code;

    /**
     * msg
     */
    private final String message;

    public BusinessException(MsgEnum rtnCodeEnum) {
        this.code = rtnCodeEnum.getCode();
        this.message = rtnCodeEnum.getMessage();
    }

    public BusinessException(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public BusinessException(String message, int code, Throwable e) {
        super(message, e);
        this.message = message;
        this.code = code;
    }

    @Override
    public int getCode() {
        return this.code;
    }

    @Override
    public String getMessage() {
        return this.message;
    }

}